package com.yijiu.wiki.controller;

import com.yijiu.wiki.domain.Test;
import com.yijiu.wiki.service.TestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ligaojian
 * @version 1.0
 * @description: 测试接口 hello world
 * @date 2021/10/30 1:16
 */
@RestController
public class TestController {

    @Value("${test.hello}")
    private String testHello;

    @Resource
    private TestService testService;

    public TestController(TestService testService) {
        this.testService = testService;
    }

    //@RequestMapping("/hello")
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello(){
        return "Hello World!"+testHello;  //网页输入http://localhost:8880/hello 查看返回结果
    }

    @PostMapping("/hello/post")
    public String helloPost(String name) {
        return "Hello World! Post，" + name;
    }

    @GetMapping("/test/list")
    public List<Test> list(){
        return testService.list();
    }
}
